package cn.shiro.shiroservice.auth.utils;

import cn.shiro.shiroservice.auth.pojo.User;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * &#064;Time 2024 一月 星期五 17:15
 *
 * @author ShangGuan
 */
@Slf4j
public class ShiroUtils extends SecurityUtils {
    private static Logger logger = LoggerFactory.getLogger(ShiroUtils.class);


    public static User getUser(){
        Subject subject = getSubject();
        return (User)subject.getPrincipal();
    }

    public static String getUsername(){
        return  getUser().getUserName();
    }

}
